#include "bsp_g3507std.h"
#include "ti_msp_dl_config.h"
#include "user_main.h"


uint32_t g_g3507_board_order_array[G3507_BOARD_ORDER_ARRAY_LEN];
uint32_t g_g3507_board_sensor_array[G3507_BOARD_SENSOR_ARRAY_LEN];

////////////////////////////////////
////////////////////////////////////
//rgb
void marquee_light(uint8_t rgb_led_mode)
{
    if(rgb_led_mode == CLOSE_LIGHT)
    {
        DL_GPIO_clearPins( RGB_LED_PORT, RGB_LED_r_led_PIN | RGB_LED_g_led_PIN | RGB_LED_b_led_PIN);
    }

    else if(rgb_led_mode == OPEN_LIGHT)
    {
        DL_GPIO_setPins( RGB_LED_PORT, RGB_LED_r_led_PIN | RGB_LED_g_led_PIN | RGB_LED_b_led_PIN);
    }

    else if(rgb_led_mode == SLOW_MARQUEE_LIGHT)
    {
        if((g_ticks_inc / 500) % 3 == 0)
        {
            DL_GPIO_setPins(RGB_LED_PORT, RGB_LED_r_led_PIN);
            DL_GPIO_clearPins( RGB_LED_PORT, RGB_LED_g_led_PIN | RGB_LED_b_led_PIN);
        }
        else if((g_ticks_inc / 500 % 3) == 1)
        {
            DL_GPIO_setPins(RGB_LED_PORT, RGB_LED_g_led_PIN);
            DL_GPIO_clearPins( RGB_LED_PORT, RGB_LED_r_led_PIN | RGB_LED_b_led_PIN);
        }
        else if((g_ticks_inc / 500) % 3 == 2)
        {
            DL_GPIO_setPins(RGB_LED_PORT, RGB_LED_b_led_PIN);
            DL_GPIO_clearPins( RGB_LED_PORT, RGB_LED_r_led_PIN | RGB_LED_g_led_PIN);
        }
    }

    else if(rgb_led_mode == FAST_MARQUEE_LIGHT)
    {
        if((g_ticks_inc / 200) % 3 == 0)
        {
            DL_GPIO_setPins(RGB_LED_PORT, RGB_LED_r_led_PIN);
            DL_GPIO_clearPins( RGB_LED_PORT, RGB_LED_g_led_PIN | RGB_LED_b_led_PIN);
        }
        else if((g_ticks_inc / 200 % 3) == 1)
        {
            DL_GPIO_setPins(RGB_LED_PORT, RGB_LED_g_led_PIN);
            DL_GPIO_clearPins( RGB_LED_PORT, RGB_LED_r_led_PIN | RGB_LED_b_led_PIN);
        }
        else if((g_ticks_inc / 200) % 3 == 2)
        {
            DL_GPIO_setPins(RGB_LED_PORT, RGB_LED_b_led_PIN);
            DL_GPIO_clearPins( RGB_LED_PORT, RGB_LED_r_led_PIN | RGB_LED_g_led_PIN);
        }
    }
}

int g3507_board_get_sensor( uint32_t *board_sensor_array , uint32_t board_sensor_array_len  )
{

    return 0;
}

int g3507_board_set_order( uint32_t *board_order_array  , uint32_t board_order_array_len  )
{
    marquee_light(board_order_array[0]);
    return 0;
}
